﻿using System;
using System.Collections;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Plumbing;
using YArchitech.MEP;

namespace YArchitech.BIM
{
	public class HYAssistMEP
	{
		public static void UpdateFitByPipe(Pipe pipe)
		{
			IEnumerator enumerator = pipe.ConnectorManager.Connectors.GetEnumerator();
			if (enumerator == null)
			{
				return;
			}
			while (enumerator.MoveNext())
			{
				object obj = enumerator.Current;
				Connector connector = obj as Connector;
				if (connector.IsConnected)
				{
					foreach (object obj2 in connector.AllRefs)
					{
						Connector connector2 = obj2 as Connector;
						if (connector2 != null && !connector2.Owner.Id.Equals(connector.Owner.Id) && ((int)connector2.ConnectorType == 1 || (int)connector2.ConnectorType == 2 || (int)connector2.ConnectorType == 19) && !HYMathUtility.IsEqual(connector2.Radius, connector.Radius, 1E-06))
						{
							connector2.Radius = connector.Radius;
						}
					}
				}
			}
		}
	}
}
